Log1p

逐元素计算 log(1 + x) 的值,其中 x 是输入元素。该函数在 x 的值接近于零时,比直接计算 log(1 + x) 能够提供更高的精度。

\[output_i = \ln(1 + Input_i)\]
输入:
  • Input - 输入数据地址。

  • length - 计算长度。

  • core_mask - 核掩码(仅共享存储版本需要)。

输出:
  • Output - 计算结果地址。

支持平台:

FT78NE MT7004

备注

  • FT78NE 支持int8, int16, int32, fp32, fp64

  • MT7004 支持fp16, fp32, int16, int32

共享存储版本:

void i8_log1p_s(int8_t *Input, float *output, int length, int core_mask)
void i16_log1p_s(int16_t *Input, float *output, int length, int core_mask)
void i32_log1p_s(int32_t *Input, float *output, int length, int core_mask)
void hp_log1p_s(half *Input, half *output, int length, int core_mask)
void fp_log1p_s(float *Input, float *output, int length, int core_mask)
void dp_log1p_s(double *Input, double *output, int length, int core_mask)

C调用示例:

 1//FT78NE示例
 2#include <stdio.h>
 3#include <log1p.h> // 假设头文件名为 log1p.h
 4int main(int argc, char* argv[]) {
 5    float *input = (float *)0xA0000000;   //input在DDR空间
 6    float *output = (float *)0xC0000000;
 7    int length = 1000;
 8    int core_mask = 0xff;
 9    fp_log1p_s(input, output, length, core_mask);
10    return 0;
11}

私有存储版本:

void i8_log1p_p(int8_t *Input, float *output, int length)
void i16_log1p_p(int16_t *Input, float *output, int length)
void i32_log1p_p(int32_t *Input, float *output, int length)
void hp_log1p_p(half *Input, half *output, int length)
void fp_log1p_p(float *Input, float *output, int length)
void dp_log1p_p(double *Input, double *output, int length)

C调用示例:

 1//FT78NE示例
 2#include <stdio.h>
 3#include <log1p.h> // 假设头文件名为 log1p.h
 4int main(int argc, char* argv[]) {
 5    float *input = (float *)0x10000000;   //input在L2空间
 6    float *output = (float *)0x10001000;
 7    int length = 1000;
 8    fp_log1p_p(input, output, length);
 9    return 0;
10}